package de.jmda.core.util.fileset;


import java.io.File;
import java.io.IOException;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import de.jmda.core.util.fileset.FileSetDirectoriesOrJarsOnly;
import de.jmda.core.util.fileset.FileSet.RuleSetUpdateMode;

public class JUTFileSetDirectoriesOrJarsOnly
{
	private static JAXBContext jaxbContext;

	private Marshaller marshaller;

//	private Unmarshaller unmarshaller;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception
	{
		jaxbContext =
				JAXBContext.newInstance(
						new Class[]
						    {
										FileSetDirectoriesOrJarsOnly.class,
								});
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception
	{
		jaxbContext = null;
	}

	@Before
	public void setUp() throws Exception
	{
		marshaller = jaxbContext.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		
//		unmarshaller = jaxbContext.createUnmarshaller();
	}

	@After
	public void tearDown() throws Exception
	{
		marshaller = null;
	}
	
	@Test
	public void test() throws JAXBException, IOException
	{
		FileSetDirectoriesOrJarsOnly fileSetDirectoriesOrJarsOnly = new FileSetDirectoriesOrJarsOnly();
		
		fileSetDirectoriesOrJarsOnly.includeDirectoryRecursive(
				new File("c:/temp"),
				RuleSetUpdateMode.ADD_RULE);
		
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); 
		
		marshaller.marshal(fileSetDirectoriesOrJarsOnly, System.out);
	}
}